import { getToken, setToken, removeToken } from '@/utils/auth'

const state = {
  token: getToken(),
  // 一开始是空对象没有属性，后面加属性不是响应式的！！！
  UserInfo: {}
}

const mutations = {
  setToken (state, Token) {
    state.token = Token
    setToken(Token)
  },
  removeToken (state) {
    state.token = null
    removeToken()
  },
  setUserInfo (state, result) {
    state.UserInfo = result
  },
  removeUserInfo (state) {
    state.UserInfo = {}
  }
}

export default {
  namespaced: true,
  state,
  mutations
}
